/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package com.gui;

import java.awt.Component;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.JButton;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.plaf.DimensionUIResource;

import com.beans.Prospects;
import com.beans.Sorties;
import com.beans.SortiesDetails;
import com.metier.ProspectsMetier;
import com.metier.SortiesMetier;

/**
 *
 * @author moussa
 */
public class PanelModifierSorties extends javax.swing.JPanel {
SortiesMetier sortieMetier;
String referenceCorrespondant;
    /**
     * Creates new form PanelAjouterSorties
     */
	 public PanelModifierSorties() {
	       //initComponents();
		 sortieMetier=new SortiesMetier();
	    }
    public PanelModifierSorties(JButton  bouttonAnnuler) {
        initComponents(bouttonAnnuler);
    }

	
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents(JButton  boutonAnnuler) {

        jLabelNumero = new javax.swing.JLabel();
        textNumero = new javax.swing.JTextField();
        jLabel1 = new javax.swing.JLabel();
        textReference = new javax.swing.JTextField();
        jLabelUserCreator = new javax.swing.JLabel();
        textResponsable = new javax.swing.JTextField();
        jLabelMontant = new javax.swing.JLabel();
        textMontant = new javax.swing.JTextField();
        jLabelType = new javax.swing.JLabel();
        jLabelDateCreation = new javax.swing.JLabel();
        dateCreation = new com.toedter.calendar.JDateChooser();
        jLabelDateEcheanche = new javax.swing.JLabel();
        dateEcheance = new com.toedter.calendar.JDateChooser();
        jLabelDateExacte = new javax.swing.JLabel();
        dateExate = new com.toedter.calendar.JDateChooser();
        comboxEtat = new javax.swing.JComboBox();
        buttonValier = new javax.swing.JButton();
        buttonAnnuler = new javax.swing.JButton();

        setBackground(new java.awt.Color(128, 130, 133));
        setBorder(javax.swing.BorderFactory.createMatteBorder(1, 1, 1, 1, new java.awt.Color(123, 153, 255)));
        setMaximumSize(new java.awt.Dimension(1050, 405));
        setMinimumSize(new java.awt.Dimension(1050, 405));

        jLabelNumero.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabelNumero.setForeground(new java.awt.Color(255, 255, 255));
        jLabelNumero.setText("Numero :");

        textNumero.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                textNumeroActionPerformed(evt);
            }
        });

        jLabel1.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabel1.setForeground(new java.awt.Color(255, 255, 255));
        jLabel1.setText("Référence :");

        jLabelUserCreator.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabelUserCreator.setForeground(new java.awt.Color(255, 255, 255));
        jLabelUserCreator.setText("Resposable:");

        jLabelMontant.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabelMontant.setForeground(new java.awt.Color(255, 255, 255));
        jLabelMontant.setText("Montant :");

        jLabelType.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabelType.setForeground(new java.awt.Color(255, 255, 255));
        jLabelType.setText("Type :");

        jLabelDateCreation.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabelDateCreation.setForeground(new java.awt.Color(255, 255, 255));
        jLabelDateCreation.setText("Date Creation :");

        jLabelDateEcheanche.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabelDateEcheanche.setForeground(new java.awt.Color(255, 255, 255));
        jLabelDateEcheanche.setText("Date Echéanche :");

        jLabelDateExacte.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        jLabelDateExacte.setForeground(new java.awt.Color(255, 255, 255));
        jLabelDateExacte.setText("Date Exacte :");

        comboxEtat.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        comboxEtat.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Commande", "Reception", "Facture", "Devis" }));

        buttonValier.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        buttonValier.setText("Valider");
        buttonValier.addActionListener(new ActionListener() {

			public void actionPerformed(ActionEvent arg0) {
				// TODO Auto-generated method stub

				if (JOptionPane.showConfirmDialog(getFrame(),
						"Voulez-vous vraiment confirmer la modification?",
						"Information", JOptionPane.YES_NO_OPTION) == JOptionPane.YES_OPTION) {
					SortiesMetier sortieMetier = new SortiesMetier();
					 Sorties SortitoModif = new Sorties();
					String referenceToModify = getReferenceCorrespondant();
					
					SortitoModif = sortieMetier
							.findSortieByReference(referenceToModify);
					
					SortitoModif.setSortUserCreate(textResponsable.getText());
					SortitoModif.setSortDate(dateExate.getDate());
					SortitoModif.setSortDateEcheance(dateEcheance.getDate());
					SortitoModif.setSortMontant(Double.parseDouble(textMontant.getText()));
					SortitoModif.setSortNum(textNumero.getText());
					SortitoModif.setSortRef(textReference.getText());
					SortitoModif.setSortType((String) comboxEtat.getSelectedItem());
					
					
					sortieMetier.testUpdate(SortitoModif);

					JOptionPane.showMessageDialog(null,
							" La modification a bien réussi");
					
				}
			}

			
		});
        
        buttonAnnuler.setFont(new java.awt.Font("Verdana", 3, 14)); // NOI18N
        buttonAnnuler.setText("Annuler");

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap(99, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabelType, javax.swing.GroupLayout.PREFERRED_SIZE, 95, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelDateEcheanche)
                    .addComponent(jLabelUserCreator)
                    .addComponent(jLabelNumero))
                .addGap(26, 26, 26)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                        .addComponent(dateEcheance, javax.swing.GroupLayout.PREFERRED_SIZE, 163, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addComponent(comboxEtat, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(textResponsable, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(150, 150, 150)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                    .addGroup(layout.createSequentialGroup()
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelDateExacte, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelDateCreation))
                        .addGap(18, 18, 18)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(dateExate, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dateCreation, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabelMontant, javax.swing.GroupLayout.PREFERRED_SIZE, 117, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(textMontant, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(layout.createSequentialGroup()
                        .addComponent(jLabel1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(textReference, javax.swing.GroupLayout.PREFERRED_SIZE, 166, javax.swing.GroupLayout.PREFERRED_SIZE)))
                .addGap(169, 169, 169))
            .addGroup(layout.createSequentialGroup()
                .addGap(319, 319, 319)
                .addComponent(buttonValier)
                .addGap(253, 253, 253)
                .addComponent(boutonAnnuler)
                .addGap(163, 163, 163))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(41, Short.MAX_VALUE)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textReference, javax.swing.GroupLayout.PREFERRED_SIZE, 30, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelNumero)
                    .addComponent(textNumero, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(37, 37, 37)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelMontant, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(textMontant, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelUserCreator)
                    .addComponent(textResponsable, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(35, 35, 35)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabelDateCreation, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabelType, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(comboxEtat, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(dateCreation, javax.swing.GroupLayout.PREFERRED_SIZE, 32, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(17, 17, 17)
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(layout.createSequentialGroup()
                        .addGap(27, 27, 27)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(jLabelDateExacte, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(dateExate, javax.swing.GroupLayout.PREFERRED_SIZE, 29, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(46, 46, 46))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
                        .addGap(24, 24, 24)
                        .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addComponent(dateEcheance, javax.swing.GroupLayout.PREFERRED_SIZE, 28, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabelDateEcheanche, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)))
                .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(buttonValier)
                    .addComponent(boutonAnnuler))
                .addGap(49, 49, 49))
        );
    }// </editor-fold>//GEN-END:initComponents

    private void textNumeroActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_textNumeroActionPerformed
        // TODO add your handling code here:
    }//GEN-LAST:event_textNumeroActionPerformed

    public javax.swing.JComboBox getjComboBox1() {
		return comboxEtat;
	}
	public void setjComboBox1(javax.swing.JComboBox jComboBox1) {
		this.comboxEtat = jComboBox1;
	}
	public com.toedter.calendar.JDateChooser getjDateChooser1() {
		return dateCreation;
	}
	public void setjDateChooser1(com.toedter.calendar.JDateChooser jDateChooser1) {
		this.dateCreation = jDateChooser1;
	}
	public com.toedter.calendar.JDateChooser getjDateChooser2() {
		return dateEcheance;
	}
	public void setjDateChooser2(com.toedter.calendar.JDateChooser jDateChooser2) {
		this.dateEcheance = jDateChooser2;
	}
	public com.toedter.calendar.JDateChooser getjDateChooser3() {
		return dateExate;
	}
	public void setjDateChooser3(com.toedter.calendar.JDateChooser jDateChooser3) {
		this.dateExate = jDateChooser3;
	}
	public javax.swing.JLabel getjLabelUserCreator() {
		return jLabelUserCreator;
	}
	public void setjLabelUserCreator(javax.swing.JLabel jLabelUserCreator) {
		this.jLabelUserCreator = jLabelUserCreator;
	}
	public javax.swing.JTextField getjTextFieldMontant() {
		return textMontant;
	}
	public void setjTextFieldMontant(javax.swing.JTextField jTextFieldMontant) {
		this.textMontant = jTextFieldMontant;
	}
	public javax.swing.JTextField getjTextFieldNumero() {
		return textNumero;
	}
	public void setjTextFieldNumero(javax.swing.JTextField jTextFieldNumero) {
		this.textNumero = jTextFieldNumero;
	}
	public javax.swing.JTextField getjTextFieldReference() {
		return textReference;
	}
	public void setjTextFieldReference(javax.swing.JTextField jTextFieldReference) {
		this.textReference = jTextFieldReference;
	}
	public javax.swing.JTextField getjTextFieldUserCreator() {
		return textResponsable;
	}
	public void setjTextFieldUserCreator(
			javax.swing.JTextField jTextFieldUserCreator) {
		this.textResponsable = jTextFieldUserCreator;
	}
	

    /**
	 * @return the buttonAnnuler
	 */
	public javax.swing.JButton getButtonAnnuler() {
		return buttonAnnuler;
	}
	/**
	 * @param buttonAnnuler the buttonAnnuler to set
	 */
	public void setButtonAnnuler(javax.swing.JButton buttonAnnuler) {
		this.buttonAnnuler = buttonAnnuler;
	}
	/**
	 * @return the buttonValier
	 */
	public javax.swing.JButton getButtonValier() {
		return buttonValier;
	}
	/**
	 * @param buttonValier the buttonValier to set
	 */
	public void setButtonValier(javax.swing.JButton buttonValier) {
		this.buttonValier = buttonValier;
	}
	/**
	 * @return the comboxEtat
	 */
	public javax.swing.JComboBox getComboxEtat() {
		return comboxEtat;
	}
	/**
	*
	 
	
	

	
	

	/**
	 * @return the referenceCorrespondant
	 */
	public String getReferenceCorrespondant() {
		return referenceCorrespondant;
	}
	/**
	 * @param referenceCorrespondant the referenceCorrespondant to set
	 */
	public void setReferenceCorrespondant(String referenceCorrespondant) {
		this.referenceCorrespondant = referenceCorrespondant;
	}


	// Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton buttonAnnuler;
    private javax.swing.JButton buttonValier;
    private javax.swing.JComboBox comboxEtat;
    private com.toedter.calendar.JDateChooser dateCreation;
    private com.toedter.calendar.JDateChooser dateEcheance;
    private com.toedter.calendar.JDateChooser dateExate;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabelDateCreation;
    private javax.swing.JLabel jLabelDateEcheanche;
    private javax.swing.JLabel jLabelDateExacte;
    private javax.swing.JLabel jLabelMontant;
    private javax.swing.JLabel jLabelNumero;
    private javax.swing.JLabel jLabelType;
    private javax.swing.JLabel jLabelUserCreator;
    private javax.swing.JTextField textMontant;
    private javax.swing.JTextField textNumero;
    private javax.swing.JTextField textReference;
    private javax.swing.JTextField textResponsable;
    // End of variables declaration//GEN-END:variables
    
    
	public void setComboxEtat(javax.swing.JComboBox comboxEtat) {
		this.comboxEtat = comboxEtat;
	}
	public com.toedter.calendar.JDateChooser getDateCreation() {
		return dateCreation;
	}
	public void setDateCreation(com.toedter.calendar.JDateChooser dateCreation) {
		this.dateCreation = dateCreation;
	}
	public com.toedter.calendar.JDateChooser getDateEcheance() {
		return dateEcheance;
	}
	public void setDateEcheance(com.toedter.calendar.JDateChooser dateEcheance) {
		this.dateEcheance = dateEcheance;
	}
	public com.toedter.calendar.JDateChooser getDateExate() {
		return dateExate;
	}
	public void setDateExate(com.toedter.calendar.JDateChooser dateExate) {
		this.dateExate = dateExate;
	}
	public javax.swing.JTextField getTextMontant() {
		return textMontant;
	}
	public void setTextMontant(javax.swing.JTextField textMontant) {
		this.textMontant = textMontant;
	}
	public javax.swing.JTextField getTextNumero() {
		return textNumero;
	}
	public void setTextNumero(javax.swing.JTextField textNumero) {
		this.textNumero = textNumero;
	}
	public javax.swing.JTextField getTextReference() {
		return textReference;
	}
	public void setTextReference(javax.swing.JTextField textReference) {
		this.textReference = textReference;
	}
	public javax.swing.JTextField getTextResponsable() {
		return textResponsable;
	}
	public void setTextResponsable(javax.swing.JTextField textResponsable) {
		this.textResponsable = textResponsable;
	}

	
	private JPanel getFrame() {
		// TODO Auto-generated method stub
		return this;
	}
	
}
